//
//  SINACustomPickView.m
//  sinashebao
//
//  Created by  androidlongs on 2017/12/22.
//  Copyright © 2017年  androidlongs. All rights reserved.
//

#import "SINACommonTimePickView.h"

@interface SINACommonTimePickView()<UIPickerViewDataSource, UIPickerViewDelegate>
/** 1.选中的字符串 */
@property (nonatomic, strong, nullable)NSString *selectedTitle;



//年
@property (nonatomic, strong, nullable)NSString *selectYear;
@property (nonatomic, assign)NSInteger selectYearPos;
@property (nonatomic, strong, nullable)NSMutableArray *yearArray;

//月
@property (nonatomic, strong, nullable)NSString *selectMon;
@property (nonatomic, assign)NSInteger selectMonPos;
@property (nonatomic, strong, nullable)NSMutableArray *monArray;

//日
@property (nonatomic, strong, nullable)NSString *selectDay;
@property (nonatomic, assign)NSInteger selectDayPos;
@property (nonatomic, strong, nullable)NSMutableArray *dayArray;

//时
@property (nonatomic, strong, nullable)NSString *selectHoure;
@property (nonatomic, assign)NSInteger selectHourPos;
@property (nonatomic, strong, nullable)NSMutableArray *hourArray;

//分
@property (nonatomic, strong, nullable)NSString *selectMin;
@property (nonatomic, assign)NSInteger selectMinPos;
@property (nonatomic, strong, nullable)NSMutableArray *minArray;

@property (nonatomic, strong, nullable)NSString *selectSec;
@property (nonatomic, assign)NSInteger selectSecPos;
@property (nonatomic, strong, nullable)NSMutableArray *secArray;


@end

@implementation SINACommonTimePickView
@dynamic delegate;

- (void)initPickView
{
    [super initPickView];
    
    _yearArray=[[NSMutableArray alloc]init];
    _monArray=[[NSMutableArray alloc]init];
    _dayArray=[[NSMutableArray alloc]init];
    
    
    _hourArray=[[NSMutableArray alloc]init];
    _minArray=[[NSMutableArray alloc]init];
    _secArray=[[NSMutableArray alloc]init];
    
    //年月日 时分秒
    _currentTimeStyle=YEAER_MAONTH_DAY_HOURE_MIN_SEC;
    
    
    
    self.pickerView.frame=CGRectMake(10,  54, self.contentView.frame.size.width-20, self.contentView.frame.size.height-80);
    self.diviLabel.frame=CGRectMake(11, self.contentView.frame.size.height/2-12, 5, 51);
    [self.pickerView setDelegate:self];
    [self.pickerView setDataSource:self];
    
    
    
    
    //获取当前的年
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSUInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:[NSDate date]];
    NSInteger currentYear =  dateComponent.year;
    
    
    //当前的月
    NSInteger currentMonth =dateComponent.month;
    NSInteger currentDay =dateComponent.day;
    
    NSInteger currentHour =dateComponent.hour;
    NSInteger currentMin =dateComponent.minute;
    NSInteger currentSecond =dateComponent.second;
    
    self.selectMonPos = currentMonth-1;
    self.selectDayPos = currentDay-1;
    self.selectHourPos = currentHour;
    self.selectMinPos = currentMin;
    self.selectSecPos = currentSecond;
    
    self.selectYear=[NSString stringWithFormat:@"%ld",(long)currentYear];
    self.selectMon=[NSString stringWithFormat:@"%ld",(long)currentMonth];
    self.selectDay=[NSString stringWithFormat:@"%ld",(long)currentDay];
    
    self.selectHoure=[NSString stringWithFormat:@"%ld",(long)currentHour];
    self.selectMin=[NSString stringWithFormat:@"%ld",(long)currentMin];
    self.selectSec=[NSString stringWithFormat:@"%ld",(long)currentSecond];
    //年
    for (NSInteger i=1970; i<=currentYear; i++) {
        [self.yearArray addObject:[NSString stringWithFormat:@"%ld",(long)i]];
    }
    self.selectYearPos = self.yearArray.count-1;
    
    NSInteger dayNumber = [self updateCurrentMonthDayNumber:currentYear andWithMonth:currentMonth];
    
    
    
    
    //月
    for (NSInteger i=1; i<=12; i++) {
        [self.monArray addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    //日
    for (NSInteger i=1; i<=dayNumber; i++) {
        [self.dayArray addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    
    //时
    for (NSInteger i=0; i<24; i++) {
        [self.hourArray addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    //分
    for (NSInteger i=0; i<60; i++) {
        [self.minArray addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    
    //秒
    for (NSInteger i=0; i<60; i++) {
        [self.secArray addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    
}

//计算当前月的时间
//month 当前月
//return 天数
-(NSInteger) updateCurrentMonthDayNumber:(NSInteger)currentYear andWithMonth:(NSInteger)month{
    NSInteger dayNumber;
    switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            dayNumber=31;
            break;
        case 2:{
            if (currentYear%4==0||currentYear%400==0) {
                dayNumber=29;
            }else{
                dayNumber = 28;
            }
        }
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            dayNumber=30;
            break;
            
        default:
            dayNumber=31;
            break;
    }
    
    return dayNumber;
}

//默认
-(void)comTimePicViewDefaultSelect:(SINACommonTimePickView *)customPickView andWithYear:(NSInteger)year andWithMonth:(NSInteger)mon andWithDay:(NSInteger)day andWithHoure:(NSInteger )houre andWithMin:(NSInteger)min andWithSec:(NSInteger)sec{
    
    if ([self.yearArray containsObject:[NSString stringWithFormat:@"%ld",year]]) {
        NSInteger index = [self.yearArray indexOfObject:[NSString stringWithFormat:@"%ld",year]];
        self.selectYearPos = index;
    }else{
        self.selectYearPos =self.yearArray.count-1;
    }
    if ([self.monArray containsObject:[NSString stringWithFormat:@"%ld",mon]]) {
        NSInteger index = [self.monArray indexOfObject:[NSString stringWithFormat:@"%ld",mon]];
        self.selectMonPos = index;
    }
    if ([self.dayArray containsObject:[NSString stringWithFormat:@"%ld",day]]) {
        NSInteger index = [self.dayArray indexOfObject:[NSString stringWithFormat:@"%ld",day]];
        self.selectDayPos = index;
    }
    
    if ([self.hourArray containsObject:[NSString stringWithFormat:@"%ld",houre]]) {
        NSInteger index = [self.hourArray indexOfObject:[NSString stringWithFormat:@"%ld",houre]];
        self.selectHourPos = index;
    }
    if ([self.minArray containsObject:[NSString stringWithFormat:@"%ld",min]]) {
        NSInteger index = [self.minArray indexOfObject:[NSString stringWithFormat:@"%ld",min]];
        self.selectMinPos = index;
    }
    if ([self.secArray containsObject:[NSString stringWithFormat:@"%ld",sec]]) {
        NSInteger index = [self.secArray indexOfObject:[NSString stringWithFormat:@"%ld",sec]];
        self.selectSecPos = index;
    }
}

// 返回多少列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        //年月日 时分秒
        return 6;
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        //年月日 时分
        return 5;
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        //年月日 时
        return 4;
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        //年月日
        return 3;
    }
    else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        //时分秒
        return 3;
    }else{
        //时分
        return 2;
    }
}
// 返回每列的行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        //年月日 时分秒
        if (component==0) {
            return  self.yearArray.count;
        }else if (component==1) {
            return  self.monArray.count;
        }else if (component==2) {
            return  self.dayArray.count;
        }else if (component==3) {
            return  self.hourArray.count;
        }else if (component==4) {
            return  self.minArray.count;
        }else  {
            return  self.secArray.count;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        if (component==0) {
            return  self.yearArray.count;
        }else if (component==1) {
            return  self.monArray.count;
        }else if (component==2) {
            return  self.dayArray.count;
        }else if (component==3) {
            return  self.hourArray.count;
        }else{
            return  self.minArray.count;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        if (component==0) {
            return  self.yearArray.count;
        }else if (component==1) {
            return  self.monArray.count;
        }else if (component==2) {
            return  self.dayArray.count;
        }else {
            return  self.hourArray.count;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        if (component==0) {
            return  self.yearArray.count;
        }else if (component==1) {
            return  self.monArray.count;
        }else  {
            return  self.dayArray.count;
        }
    }else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        //时分秒
        if (component==0) {
            return  self.hourArray.count;
        }else if (component==1) {
            return  self.minArray.count;
        }else  {
            return  self.secArray.count;
        }
    }else{
        //时分
        if (component==0) {
            return  self.hourArray.count;
        }else  {
            return  self.minArray.count;
        }
    }
    
}
// 返回pickerView的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 48;
}
// 反回pickerView的宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
    
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        
        if (component==0) {
            return self.frame.size.width/5;
        }else if (component==1) {
            return self.frame.size.width/8;
        }else if (component==2) {
            return self.frame.size.width/8;
        }else if (component==3) {
            return self.frame.size.width/6;
        }else if (component==4) {
            return self.frame.size.width/8;
        }else  {
            return self.frame.size.width/8;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        if (component==0) {
            return self.frame.size.width/4;
        }else if (component==1) {
            return self.frame.size.width/7;
        }else if (component==2) {
            return self.frame.size.width/7;
        }else if (component==3) {
            return self.frame.size.width/5;
        }else {
            return self.frame.size.width/7;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        if (component==0) {
            return self.frame.size.width/4;
        }else if (component==1) {
            return self.frame.size.width/5;
        }else if (component==2) {
            return self.frame.size.width/6;
        }else  {
            return self.frame.size.width/6;
        }
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        if (component==0) {
            return self.frame.size.width/4;
        }else if (component==1) {
            return self.frame.size.width/3;
        }else {
            return self.frame.size.width/4;
        }
    }else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        if (component==0) {
            return self.frame.size.width/4;
        }else if (component==1) {
            return self.frame.size.width/3;
        }else {
            return self.frame.size.width/4;
        }
    }else{
        return self.frame.size.width/4;
    }
    
}
// 选中 每行的内容
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    
    
    NSString *rowString =[NSString stringWithFormat:@"%ld",row];
    if (row<10) {
        rowString =[NSString stringWithFormat:@"0%ld",row];
    }
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        [self timedidSelectRow1:row inComponent:component];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        [self timedidSelectRow1:row inComponent:component];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        [self timedidSelectRow1:row inComponent:component];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        [self timedidSelectRow1:row inComponent:component];
    }else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        //时分秒
    }else{
        //时分
    }
    
}

- (void)timedidSelectRow1:(NSInteger)row inComponent:(NSInteger)component{
    NSString *rowString;
    switch (component) {
        case 0:{
            rowString = self.yearArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            self.selectYearPos = row;
            self.selectYear = rowString;
            
            DLog(@"当前选中 %@年 %@月 %@日",self.selectYear,self.selectMon,self.selectDay);
            if ([self.selectMon integerValue]==2) {
                NSInteger dayNumber;
                if ([self.selectYear integerValue]%4==0||[self.selectYear integerValue]%400==0) {
                    dayNumber=29;
                }else{
                    dayNumber = 28;
                }
                [self.dayArray  removeAllObjects];
                for (NSInteger i=1; i<=dayNumber; i++) {
                    [self.dayArray addObject:[NSString stringWithFormat:@"%ld",i]];
                }
                [self.pickerView reloadComponent:2];
                if (self.selectDayPos>=self.dayArray.count) {
                    self.selectDayPos=self.dayArray.count-1;
                }
                [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
            }
        }
            break;
        case 1:{
            rowString = self.monArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            self.selectMinPos=row;
            self.selectMon = rowString;
            NSInteger dayNumber =[self updateCurrentMonthDayNumber:[self.selectYear integerValue] andWithMonth:row+1];
            
            
            
            [self.dayArray removeAllObjects];
            for (NSInteger i=1; i<=dayNumber; i++) {
                [self.dayArray addObject:[NSString stringWithFormat:@"%ld",i]];
            }
            [self.pickerView reloadComponent:2];
            if (self.selectDayPos>=self.dayArray.count) {
                self.selectDayPos=self.dayArray.count-1;
            }
            
            [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
        }
            break;
        case 2:
        {
            rowString = self.dayArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            
            self.selectDayPos=row;
            self.selectDay = rowString;
        }
            break;
        case 3:
        {
            rowString = self.hourArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            self.selectHourPos=row;
            self.selectHoure = rowString;
        }
            break;
        case 4:
        {
            rowString = self.minArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            self.selectMinPos=row;
            self.selectMin = rowString;
        }
            break;
        case 5:
        {
            rowString = self.secArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            self.selectSec = rowString;
        }
            break;
            
        default:
            break;
    }
}
// 返回pickerView 每行的view
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView *)view
{
    
    
    
    UIView *rowView = [[UIView alloc]init];
    
    UILabel *label = [[UILabel alloc]init];
    label.font=[UIFont systemFontOfSize:18];
    [label setTextAlignment:NSTextAlignmentLeft];
    
    
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        [self initViewDataFunction1:label andWithComponent:component andWithIndexRow:row];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        [self initViewDataFunction1:label andWithComponent:component andWithIndexRow:row];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        [self initViewDataFunction1:label andWithComponent:component andWithIndexRow:row];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        [self initViewDataFunction1:label andWithComponent:component andWithIndexRow:row];
        if (component==0) {
            [label setTextAlignment:NSTextAlignmentRight];
             label.frame=CGRectMake(0, 0, self.frame.size.width/4, 48);
        }else if(component==1){
            [label setTextAlignment:NSTextAlignmentCenter];
             label.frame=CGRectMake(25, 0, self.frame.size.width/4, 48);
        }else{
            [label setTextAlignment:NSTextAlignmentLeft];
             label.frame=CGRectMake(15, 0, self.frame.size.width/4, 48);
        }
       
    }else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        //时分秒
         [self initViewDataFunction2:label andWithComponent:component andWithIndexRow:row];
        if (component==0) {
            [label setTextAlignment:NSTextAlignmentRight];
            label.frame=CGRectMake(0, 0, self.frame.size.width/4, 48);
        }else if(component==1){
            [label setTextAlignment:NSTextAlignmentCenter];
            label.frame=CGRectMake(25, 0, self.frame.size.width/4, 48);
        }else{
            [label setTextAlignment:NSTextAlignmentLeft];
            label.frame=CGRectMake(15, 0, self.frame.size.width/4, 48);
        }
    }else{
        //时分
        [self initViewDataFunction2:label andWithComponent:component andWithIndexRow:row];
        if (component==0) {
            [label setTextAlignment:NSTextAlignmentRight];
            label.frame=CGRectMake(0, 0, self.frame.size.width/4, 48);
        }else {
            [label setTextAlignment:NSTextAlignmentCenter];
            label.frame=CGRectMake(0, 0, self.frame.size.width/4, 48);
        }
    }
    
    [rowView addSubview:label];
    
    return rowView;
}
-(void)initViewDataFunction1:(UILabel*)label andWithComponent:(NSInteger) component andWithIndexRow:(NSInteger)row{
    label.frame=CGRectMake(0, 0, self.frame.size.width/6, 48);
    switch (component) {
        case 0:{
            NSString * rowString=self.yearArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.frame=CGRectMake(10, 0, self.frame.size.width/6, 48);
            label.text=[NSString stringWithFormat:@"%@年",rowString];
        }
            
            break;
        case 1:
        {
            NSString * rowString=self.monArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@月",rowString];
        }
            break;
        case 2:{
            NSString * rowString=self.dayArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@日",rowString];
        }
            break;
        case 3:
        {
            label.textAlignment = NSTextAlignmentCenter;
            NSString * rowString=self.hourArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@时",rowString];
        }
            break;
        case 4:
        {
            NSString * rowString=self.minArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@分",rowString];
        }
            break;
        case 5:
        {
            NSString * rowString=self.secArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@秒",rowString];
        }
            break;
            
        default:
            break;
    }
}
-(void)initViewDataFunction2:(UILabel*)label andWithComponent:(NSInteger) component andWithIndexRow:(NSInteger)row{
    label.frame=CGRectMake(0, 0, self.frame.size.width/6, 48);
    switch (component) {
        case 0:{
            NSString * rowString=self.hourArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.frame=CGRectMake(10, 0, self.frame.size.width/6, 48);
            label.text=[NSString stringWithFormat:@"%@时",rowString];
        }
            
            break;
        case 1:
        {
            NSString * rowString=self.minArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@分",rowString];
        }
            break;
        case 2:{
            NSString * rowString=self.secArray[row];
            if ([rowString integerValue]<10) {
                rowString =[NSString stringWithFormat:@"0%@",rowString];
            }
            label.text=[NSString stringWithFormat:@"%@秒",rowString];
        }
            break;
        
        default:
            break;
    }
}

-(void) show{
    [super show];
    [self.pickerView reloadAllComponents];
    if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN_SEC) {
        [self.pickerView selectRow:self.selectYearPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMonPos inComponent:1 animated:YES];
        [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
        
        [self.pickerView selectRow:self.selectHourPos inComponent:3 animated:YES];
        [self.pickerView selectRow:self.selectMinPos inComponent:4 animated:YES];
        [self.pickerView selectRow:self.selectSecPos inComponent:5 animated:YES];
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE_MIN) {
        [self.pickerView selectRow:self.selectYearPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMonPos inComponent:1 animated:YES];
        [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
        
        [self.pickerView selectRow:self.selectHourPos inComponent:3 animated:YES];
        [self.pickerView selectRow:self.selectMinPos inComponent:4 animated:YES];
        
    }
    else if (self.currentTimeStyle==YEAER_MAONTH_DAY_HOURE) {
        [self.pickerView selectRow:self.selectYearPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMonPos inComponent:1 animated:YES];
        [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
        
        [self.pickerView selectRow:self.selectHourPos inComponent:3 animated:YES];
       
    }else if (self.currentTimeStyle==YEAER_MAONTH_DAY) {
        [self.pickerView selectRow:self.selectYearPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMonPos inComponent:1 animated:YES];
        [self.pickerView selectRow:self.selectDayPos inComponent:2 animated:YES];
       
    }
    else if (self.currentTimeStyle==HOURE_MIN_SEC) {
        [self.pickerView selectRow:self.selectHourPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMinPos inComponent:1 animated:YES];
        [self.pickerView selectRow:self.selectSecPos inComponent:2 animated:YES];
        
    }else{
        [self.pickerView selectRow:self.selectHourPos inComponent:0 animated:YES];
        [self.pickerView selectRow:self.selectMinPos inComponent:1 animated:YES];
    }
}

#pragma mark -点击确定按钮
- (void)clickConfirmButton
{
    if (self.delegate&&[self.delegate respondsToSelector:@selector(commonTimeSelectPickView:andWithYear:andWithMonth:andWithDay:andWithHoure:andWithMin:andWithSec:)]) {
        [self.delegate commonTimeSelectPickView:self andWithYear:self.selectYear andWithMonth:self.selectMon andWithDay:self.selectDay andWithHoure:self.selectHoure andWithMin:self.selectMin andWithSec:self.selectSec];
    }
    [super clickConfirmButton];
}
-(void)clickCancelButton{
    if (self.delegate&&[self.delegate respondsToSelector:@selector(dismissServiceTimeSelectPickView:)]) {
        [self.delegate dismissServiceTimeSelectPickView:self];
    }
    
    [super clickCancelButton];
}




@end
